package com.chaopei.user_mng.mapper;

import com.chaopei.user_mng.entity.UserInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * @Author Corday 天涯
 * @Date 2022/4/28 17:28
 * mybatis除了查询返回是对象外;其它的增删改一律为记录条数,不成功返回0
 */
@Mapper
public interface UserInfoMapper {
//    先查询用户是否存在
    @Select("select id from user_info where userName=#{userName}")
    Integer selectUserInfoByUserName(String userName);
    @Insert("insert into user_info(userName,realName,password,regDate) values(#{userName}," +
            "#{realName},#{password},#{regDate})")
    int insertUserInfo(UserInfo userInfo);
//   登录,通过xml方式完成
    Integer selectUserByUserNameAndPassword(@Param("userName") String userName, @Param("password") String password);
//   修改密码,通过xml方式完成
    int updateOldPassword(String userName,String oldPassword,String newPassword);
//    找回密码
    String selectQuestion(String userName);
    //先回答问题,需要在业务层判断
    Integer selectAnswer(String answer);
    int updatePassword(String userName,String newPassword);

}
